package edu.spec.teacher.model;

import edu.spec.basic.model.User;
import edu.spec.basic.model.enumeration.FinishStatus;

import javax.persistence.*;
import java.util.Date;

/**
 * Author       : MadFrog
 * Date         : 2018/10/15 9:50
 * Description  : 教工选举映射，用于记录选举人的选票情况
 */
@Entity
@Table(name = "t_user_elect")
public class UserElect {
    /**
     * 主键
     */
    private Integer id;
    /**
     * 教工
     */
    private User user;
    /**
     * 选举主题
     */
    private Elect elect;
    /**
     * 选举结果
     * 以字符串形式存放被选举教工的主键，例如“1,2,3,4”
     */
    private String result;
    /**
     * 完成时间
     */
    private Date finishDate;
    /**
     * 完成状态
     */
    private FinishStatus finishStatus;

    public UserElect() {
    }

    public UserElect(User user, Elect elect) {
        this.user = user;
        this.elect = elect;
        this.finishStatus = FinishStatus.UNFINISH;
    }

    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "user_id")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne
    @JoinColumn(name = "elect_id")
    public Elect getElect() {
        return elect;
    }

    public void setElect(Elect elect) {
        this.elect = elect;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    @Column(name = "finish_date")
    public Date getFinishDate() {
        return finishDate;
    }

    public void setFinishDate(Date finishDate) {
        this.finishDate = finishDate;
    }

    @Column(name = "finish_status")
    public FinishStatus getFinishStatus() {
        return finishStatus;
    }

    public void setFinishStatus(FinishStatus finishStatus) {
        this.finishStatus = finishStatus;
    }
}
